﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using nplJobsCommon.Common;
using System.Data;
using System.Data.SqlClient;

namespace nplJobsDAL.Common
{
    public class CityDAL:DataAccessBase
    {
        public List<City> GetList(City obj, string strMode)
        {
            try
            {
                DataSet ds;
                DataBaseHelper dbHelper = new DataBaseHelper("[spSelectCity]");
                SqlParameter prm = new SqlParameter("@intCountry", SqlDbType.Int);
                prm.Value = obj.COUNTRYID;
                SqlParameter prm1 = new SqlParameter("@strMode", SqlDbType.Int);
                prm1.Value = strMode;

                SqlParameter[] prmCollection = { prm, prm1 };

                dbHelper.Parameters = prmCollection;
                ds = dbHelper.Run(base.ConnectionString, dbHelper.Parameters);

                List<City> results = new List<City>();
                foreach (DataRow dr in ds.Tables[0].Rows)
                {        
                    City objCity = new City();

                    MapperBase.GetInstance().MapItem(objCity, dr); ;
                    results.Add(objCity);
                }
                return results;

            }
            catch (Exception ex)
            {
                throw (ex);
            }
        }
    }
}
